package com.ict.web.controller.yzq;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ict.web.domain.PerformanceIndicators;
import com.ict.web.dto.InsertPerIndicatorsDto;
import com.ict.web.dto.QueryPerIndicatorsDto;
import com.ict.web.dto.UpdatePerIndicatorsDto;
import com.ict.web.service.IPerformanceIndicatorsService;
import com.ict.web.vo.PerIndicatorsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ict.common.annotation.Log;
import com.ict.common.core.controller.BaseController;
import com.ict.common.core.domain.AjaxResult;
import com.ict.common.enums.BusinessType;
import com.ict.common.utils.poi.ExcelUtil;
import com.ict.common.core.page.TableDataInfo;

/**
 * 绩效指标Controller
 * 
 * @author ruoyi
 * @date 2022-02-15
 */
@Api(tags = "绩效指标")
@RestController
@RequestMapping("/web/indicators")
public class PerformanceIndicatorsController extends BaseController
{
    @Autowired
    private IPerformanceIndicatorsService performanceIndicatorsService;

    /**
     * 查询绩效指标列表
     */
    @ApiOperation("查询绩效指标列表")
    //@PreAuthorize("@ss.hasPermi('web:indicators:list')")
    @GetMapping("/list")
    public TableDataInfo list()
    {
        startPage();
        List<PerIndicatorsVo> list = performanceIndicatorsService.selectPerformanceIndicatorsList();
        return getDataTable(list);
    }


    /**
     * 获取绩效指标详细信息
     */
    @ApiOperation("查询绩效详情")
    //@PreAuthorize("@ss.hasPermi('web:indicators:query')")
    @GetMapping(value = "/{indicatorsId}")
    public AjaxResult getInfo(@PathVariable("indicatorsId") Long indicatorsId)
    {
        return AjaxResult.success(performanceIndicatorsService.selectPerformanceIndicatorsByIndicatorsId(indicatorsId));
    }

    /**
     * 新增绩效指标
     */
    @ApiOperation("新增绩效指标")
   // @PreAuthorize("@ss.hasPermi('web:indicators:add')")
    @Log(title = "绩效指标", businessType = BusinessType.INSERT)
    @PostMapping("/addSave")
    public AjaxResult add( Long perId,@RequestBody List<InsertPerIndicatorsDto> addDtoS)
    {
        performanceIndicatorsService.insertPerformanceIndicators(perId,addDtoS);
        return AjaxResult.success();
    }

    /**
     * 修改绩效指标
     */
    @ApiOperation("修改绩效指标")
    //@PreAuthorize("@ss.hasPermi('web:indicators:edit')")
    @Log(title = "绩效指标", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody UpdatePerIndicatorsDto updateDto)
    {
        return toAjax(performanceIndicatorsService.updatePerformanceIndicators(updateDto));
    }

    /**
     * 删除绩效指标
     */
    @ApiOperation("删除绩效指标")
    //@PreAuthorize("@ss.hasPermi('web:indicators:remove')")
    @Log(title = "绩效指标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{indicatorsId}")
    public AjaxResult remove(@PathVariable Long indicatorsId)
    {
        return toAjax(performanceIndicatorsService.deletePerformanceIndicatorsByIndicatorsId(indicatorsId));
    }
}
